package top.tenebrous.yzl.enums;

import java.util.Arrays;

/**
 * @author yazhang6
 */

public enum FailCodeEnum {

    SERVER_NOT_FOUND(400400, "服务不存在", "server not found"),

    SERVER_PARAM_NOT_FOUND(400500, "服务参数不存在", "server param not found"),

    SERVER_TOKEN_NOT_FOUND(400300, "身份验证异常", "server token not found"),

    SERVER_NOT_RUNNING(500100, "服务不在运行状态", "server not running");

    private Integer code;

    private String zhDesc;

    private String enDesc;

    FailCodeEnum(Integer code, String zhDesc, String enDesc) {
        this.code = code;
        this.zhDesc = zhDesc;
        this.enDesc = enDesc;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getEnDesc() {
        return enDesc;
    }

    public void setEnDesc(String enDesc) {
        this.enDesc = enDesc;
    }

    public String getZhDesc() {
        return zhDesc;
    }

    public void setZhDesc(String zhDesc) {
        this.zhDesc = zhDesc;
    }
    public static FailCodeEnum getInstance(Integer code) {
        return Arrays.stream(FailCodeEnum.values()).filter(s -> s.getCode().equals(code)).findFirst().orElse(null);
    }

}
